Bee.form.DWRComboBox = Ext.extend(Ext.form.ComboBox, {
    editable: false,
    typeAhead: false,
    triggerAction: 'all',
    selectOnFocus: true,
    mode: 'remote',
    valueField: 'key',
    displayField: 'label',
    resizable: true,
    initComponent: function(){
        if (this.ds instanceof Bee.data.DWRStore) {
            this.store = this.ds;
            delete this.ds;
        }
        else {
            this.store = new Bee.data.DWRStore({
                dwr: {
                    call: this.ds.call,
                    params: this.ds.params
                },
                listeners: this.ds.listeners || null,
                fields: this.fields,
                defaultItems: this.defaultItems
            });
            delete this.ds;
        }
        if (!this.width) {
            this.width = 100;
        }
        Bee.form.DWRComboBox.superclass.initComponent.call(this);
    },
    onRender: function(ct, position){
        Bee.form.DWRComboBox.superclass.onRender.call(this, ct, position);
        if (!this.lazyInit) {
            this.doQuery(this.allQuery, true);
        }
        this.store.on('load', function(){
            if (this.getValue()) {
                this.setValue(this.getValue());
            }
        }, this);
    }
});

Ext.reg('rcombo', Bee.form.DWRComboBox);
